package com.li.youhappygo.model.vo.common;

import io.swagger.annotations.ApiModel;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Builder;
import lombok.Data;
import org.springframework.web.bind.annotation.ResponseBody;
@Data
@ApiModel("响应实体类")
public class Result<T> {
    @Schema(description = "返回状态信息",example = "操作成功")
    private String message;
    @Schema(description = "返回数据")
    private T data;
    @Schema(description = "状态代码",example = "200")
    private Integer code;

//    @Schema(description = "状态代码")
//    private ResultCode resultCode;
    public static <T> Result<T> build(T body, Integer code, String message) {
        Result<T> result = new Result<>();
        result.setData(body);
        result.setCode(code);
        result.setMessage(message);
        return result;
    }
    public static<T> Result<T> build(T obj,  ResultCode resultCode){
        return build(obj, resultCode.getCode(), resultCode.getMessage());
    }

}
